import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import actions from './actions'
import mutations from './mutations'

Vue.use(Vuex)

export default new Vuex.Store({
  state,
  actions,
  mutations
})

// 组件List.vue通过this.$store.dispatch('changeCity', city)把city传过来
// 传给actions,dispatch('changeCity', city)所以actions里面changeCity接收俩个参数ctx, city
// actions里面的changeCity方法通过ctx.commit('changeCity', city)把city传给mutations
// 最后mutations里面changeCity接收state, city改变state里面的数据
